/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package abricots.entity.state;

/**
 *
 * @author charly
 */
public class ControllableEntityState extends BasicEntityState {
   protected boolean actionUp;
   protected boolean actionDown;
   protected boolean actionRight;
   protected boolean actionLeft;

   public ControllableEntityState() {
   }

   public ControllableEntityState(boolean actionUp, boolean actionDown, boolean actionRight, boolean actionLeft, float posX, float posY, float speed, float angle, long gameTime, int entityId) {
      this.actionUp = actionUp;
      this.actionDown = actionDown;
      this.actionRight = actionRight;
      this.actionLeft = actionLeft;
      this.posX = posX;
      this.posY = posY;
      this.speed = speed;
      this.angle = angle;
      this.gameTime = gameTime;
      this.entityId = entityId;
   }

   public boolean isActionDown() {
      return actionDown;
   }

   public void setActionDown(boolean actionDown) {
      this.actionDown = actionDown;
   }

   public boolean isActionLeft() {
      return actionLeft;
   }

   public void setActionLeft(boolean actionLeft) {
      this.actionLeft = actionLeft;
   }

   public boolean isActionRight() {
      return actionRight;
   }

   public void setActionRight(boolean actionRight) {
      this.actionRight = actionRight;
   }

   public boolean isActionUp() {
      return actionUp;
   }

   public void setActionUp(boolean actionUp) {
      this.actionUp = actionUp;
   }

   @Override
   public boolean equalsRegardlessOfTime(EntityState o) {
      if (o == null) {
         return false;
      }
      if (getClass() != o.getClass()) {
         return false;
      }
      final ControllableEntityState other = (ControllableEntityState) o;
      if (this.actionUp != other.actionUp) {
         return false;
      }
      if (this.actionDown != other.actionDown) {
         return false;
      }
      if (this.actionRight != other.actionRight) {
         return false;
      }
      if (this.actionLeft != other.actionLeft) {
         return false;
      }
      if (Float.floatToIntBits(this.posX) != Float.floatToIntBits(other.posX)) {
         return false;
      }
      if (Float.floatToIntBits(this.posY) != Float.floatToIntBits(other.posY)) {
         return false;
      }
      if (Float.floatToIntBits(this.speed) != Float.floatToIntBits(other.speed)) {
         return false;
      }
      if (Float.floatToIntBits(this.angle) != Float.floatToIntBits(other.angle)) {
         return false;
      }
      if (this.entityId != other.entityId) {
         return false;
      }
      return true;
   }

   @Override
   public EntityState getCopy() {
      try {
         return (EntityState) clone();
      } catch (CloneNotSupportedException ex) {
         return null;
      }
   }

   @Override
   public String toString() {
      return "ControllableState:: actionUp=" + actionUp + ", actionDown=" + actionDown + ", actionRight=" + actionRight + ", actionLeft=" + actionLeft + super.toString();
   }

   @Override
   public boolean equals(Object obj) {
      if (obj == null) {
         return false;
      }
      if (getClass() != obj.getClass()) {
         return false;
      }
      final ControllableEntityState other = (ControllableEntityState) obj;
      if (this.actionUp != other.actionUp) {
         return false;
      }
      if (this.actionDown != other.actionDown) {
         return false;
      }
      if (this.actionRight != other.actionRight) {
         return false;
      }
      if (this.actionLeft != other.actionLeft) {
         return false;
      }
      if (Float.floatToIntBits(this.posX) != Float.floatToIntBits(other.posX)) {
         return false;
      }
      if (Float.floatToIntBits(this.posY) != Float.floatToIntBits(other.posY)) {
         return false;
      }
      if (Float.floatToIntBits(this.speed) != Float.floatToIntBits(other.speed)) {
         return false;
      }
      if (Float.floatToIntBits(this.angle) != Float.floatToIntBits(other.angle)) {
         return false;
      }
      if (this.gameTime != other.gameTime) {
         return false;
      }
      if (this.entityId != other.entityId) {
         return false;
      }
      return true;
   }

   @Override
   public int hashCode() {
      int hash = 7;
      hash = 29 * hash + (this.actionUp ? 1 : 0);
      hash = 29 * hash + (this.actionDown ? 1 : 0);
      hash = 29 * hash + (this.actionRight ? 1 : 0);
      hash = 29 * hash + (this.actionLeft ? 1 : 0);
      hash = 29 * hash + Float.floatToIntBits(this.posX);
      hash = 29 * hash + Float.floatToIntBits(this.posY);
      hash = 29 * hash + Float.floatToIntBits(this.speed);
      hash = 29 * hash + Float.floatToIntBits(this.angle);
      hash = 29 * hash + (int) (this.gameTime ^ (this.gameTime >>> 32));
      hash = 29 * hash + this.entityId;
      return hash;
   }
}
